<template>
	<view class="latestNews-container">
		<view class="informationBody">
			<text>信息</text>	
			<view class="goods-introduce">
				<textarea v-model="latestNews.recordText" id="" cols="30" rows="8" placeholder="输入信息"></textarea>
			</view>	
			<text>图片</text>
			<view class="goods-img">
				<!-- 图片 -->
				<view class="goods-image" v-for="(item, index) in latestNews.imageList" :key="index">
					<image :src="item"></image>
					<view class="delete-img" @click="deletImg(index)">
						<uni-icons type="closeempty" size="14" color="#fff"></uni-icons>
					</view>
				</view>
				<!-- 选择图片 -->
				<view class="select-image" @click="selectImage" v-if="latestNews.imageList.length < 6">
					<uni-icons type="plusempty" size="20"></uni-icons>
					<view>选择图片</view>
				</view>
			</view>
		</view>
		
		<!-- 提交 -->
		<view class="submit" @click="submit">
			<text class="submit-text">{{ '提 交 审 核' }}</text>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				latestNews: {
					// 近期动态信息
					recordText: '',
					// 近期动态图片列表
					imageList: [],
				},
				
			};
		},
		
		methods: {
			// 删除图片
			deletImg(i) {
				this.latestNews.imageList.splice(i, 1)
			},
			
			// 选择图片 
			selectImage() {
				// 将 this 重新赋值一下，因为 success 中的 this 与这里不是同一个
				const that = this
				
				uni.chooseImage({
					success: function (res) {
						that.latestNews.imageList.push('' + res.tempFilePaths)
					}
				})
			},
			
			// 提交审核
			async submit() {
				console.log(this.latestNews);
				const {data: res} = await uni.$http.get('')
				console.log(123456);
				console.log(res);
				// if(res.code !== 200 ) return uni.$showMsg()
				
			}
		},
		
		onLoad(loading) {
			
		}
	}
</script>

<style lang="scss">
.latestNews-container {
	position: relative;

	.informationBody {
		box-sizing: border-box;
		width: 100%;
		padding: 40rpx;
		padding-bottom: 210rpx;
		
		font-size: 14px;
		
		text {
			font-size: 16px;
			color: #333333;
			
		}
		
		.goods-img {
			display: flex;
			flex-wrap: wrap;
			box-sizing: border-box;
			
			width: 670rpx;
			margin: 10rpx 0 40rpx 0;
			padding: 25rpx 0 0 25rpx;
			border-radius: 10rpx;
			
			background-color: #ffffff;
			
			.goods-image {
				position: relative;
				width: 190rpx;
				height: 190rpx;
				margin: 10rpx 25rpx 25rpx 0;
				border-radius: 5px;
				
				background-color: #f5f5f5;
				
				image {
					width: 190rpx;
					height: 190rpx;
				}
				
				.delete-img {
					position: absolute;
					top: 10rpx;
					right: 10rpx;
					
					width: 40rpx;
					height: 40rpx;
					border-radius: 100%;
					
					background-color: #9d9d9d;
					text-align: center;
					line-height: 40rpx;
				}
			}
			
			.select-image {
				display: flex;
				flex-direction: column;
				justify-content: center;
				align-items: center;
				
				width: 190rpx;
				height: 190rpx;
				margin: 0 25rpx 25rpx 0;
				border-radius: 5px;
				
				background-color: #f5f5f5;
				
			}
		}
		
		.goods-introduce {
			display: flex;
			align-items: center;
			margin-top: 10rpx;
			padding: 20rpx;
			border-radius: 10rpx;
			margin-bottom: 40rpx;
			
			background-color: #ffffff;	
		}	
		
	}
	
	
	// 提交
	.submit {
		position: fixed;
		bottom: 0;
		left: 0;
		
		width: 100%;
		height: 140rpx;
		background-color: #c00000;
		z-index: 999;
		text-align: center;
		
		&::after {
			content: '';
			position: absolute;
			top: -70rpx;
			left: 0;
			width: 100%;
			height: 140rpx;
			border-radius: 100%;
			z-index: -1;
			
			background-color: #c00000;
		}
		
		.submit-text {
			font-size: 60rpx;
			color: #fff;
		}
	}
}
</style>
